<!--
 * @Author: boyyang
 * @Date: 2022-01-29 16:08:58
 * @LastEditTime: 2022-02-05 22:09:20
 * @LastEditors: boyyang
 * @Description: 
 * @FilePath: \boyyang\src\components\blog\blogItem.vue
-->

<template>
    <div class="article">
        <div class="article-title">
            <div class="title-text">{{ props.blog.blogTitle }}</div>
        </div>
        <div class="article-content">
            <img :src="props.blog.blogBg" v-if="props.blog.blogBg && props.blog.blogBg != ''" />
            <div class="content-text">
                <span>{{ props.blog.blogDesc }}</span>
                <span class="name">{{ props.blog.nickName }}</span>
                <span class="time">{{ moment(props.blog.time).format('YYYY-MM-DD hh:mm:ss') }}</span>
            </div>
        </div>

        <div class="article-bottom">
            <i
                :class="['iconfont', 'icon-dianzan1', { 'thumbed': props.blog.thumbArray && props.blog.thumbArray.includes(props.uid) }]"
                @click="iconClick(0, props.blog._id)"
            >
                <div class="thumb-num" v-show="props.blog.thumb">{{ props.blog.thumb }}</div>
            </i>
            <!-- <i class="iconfont icon-shoucang2" @click="iconClick(1, props.blog._id)"></i> -->
            <!-- <i class="iconfont icon-fenxiang1" @click="iconClick(2, props.blog._id)"></i> -->
            <i class="iconfont icon-xiangqing" @click="iconClick(3, props.blog._id)"></i>
            <i
                class="iconfont icon-shanchu"
                @click="iconClick(4, props.blog._id)"
                v-if="props.blog._openid == props.uid"
            ></i>
        </div>
    </div>
</template>

<script lang="ts" setup>
import moment from 'moment'

interface IBlogItemProps {
    blog?: any;
    uid?: string;
}

interface IBlogItemEmits {
    (e: 'iconClick', index: number, _id: string): void
}

const props = withDefaults(defineProps<IBlogItemProps>(), {

})

const emits = defineEmits<IBlogItemEmits>()

const iconClick = (index: number, _id: string) => {
    emits('iconClick', index, _id)
}

</script>

<style scoped lang="scss">
.article {
    box-sizing: border-box;
    width: 350px;
    height: 270px;
    background-color: #3d3b4f;
    margin: 15px;

    border-radius: 5px;

    box-shadow: 3px 4px 3px 2px rgba(0, 0, 0, 0.6);

    transition: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);

    position: relative;

    &:hover {
        transform: scale(1.1);
    }

    .article-title {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;

        overflow: hidden;

        .title-text {
            box-sizing: border-box;
            width: 100%;
            overflow: hidden;

            display: inline-block;
            white-space: nowrap;
            text-overflow: ellipsis;
            text-align: center;

            padding: 10px 25px 0;

            font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande",
                "Lucida Sans", Arial, sans-serif;
            font-size: 18px;
            font-weight: 500;
            color: whitesmoke;
        }
    }

    .article-content {
        box-sizing: border-box;
        padding: 25px;
        display: flex;
        justify-content: center;
        align-items: center;
        overflow: hidden;

        height: 60%;

        background-color: rgba(0, 0, 0, 0.5);
        margin-top: 10px;
        z-index: 99;

        position: relative;

        img {
            width: 100%;
            height: 340px;
            position: absolute;

            object-fit: contain;
            opacity: 0.8;
        }
        .content-text {
            box-sizing: border-box;
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 6;
            -webkit-box-orient: vertical;
            width: 100%;
            height: 100%;

            text-overflow: ellipsis;

            color: whitesmoke;

            font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS",
                sans-serif;
            font-size: 16px;
            font-weight: 500;
            z-index: 5;

            padding: 0 10px;

            .name {
                position: absolute;
                left: 5px;
                bottom: 5px;
            }

            .time {
                position: absolute;
                right: 5px;
                bottom: 5px;
            }
        }
    }

    .article-bottom {
        width: 100%;
        height: 45px;
        display: flex;
        justify-content: space-around;
        align-items: center;

        position: absolute;
        bottom: 0;

        i {
            font-size: 23px;
            color: whitesmoke;
            cursor: pointer;

            position: relative;

            &:hover {
                color: rgb(201, 72, 151);
            }
        }

        .thumb-num {
            box-sizing: border-box;
            min-width: 20px;
            min-height: 20px;
            box-sizing: border-box;
            border-radius: 100%;
            // background-color: rgb(187, 19, 19);

            // padding: 5px;

            display: flex;
            justify-content: center;
            align-items: center;
            position: absolute;
            top: -10px;
            right: -24px;
            font-size: 14px;

            color: rgb(255, 255, 255);
        }

        .thumbed {
            color: #ff2d51;
        }
    }
}
</style>
